<template>
  <div class="content">
    <img src="../../public/imgs/buysuccess/choujiang_banner.jpg" alt="">
    <div class="nav">
      您有{{cont}}次翻牌福利
    </div>

    <div class="card_content">

      <div class="item" v-for="(item,index) in cardlist" @click="selset(index)" :class="{'active':item.select}">
        <img src="../../public/imgs/buysuccess/card_default.png" alt="">
        <div class="item_sss">
          <div class="s_1">
            <span>￥</span>{{parseInt(item.money)}}</div>
          <div class="s_2">满{{parseInt(item.quota)}}元<br/> 可用</div>
          <div class="s_3">抵价券</div>
        </div>

      </div>
    </div>
    <div class="rules">
      <div class="title">活动规则</div>
      <div class="des_a">1. 每位用户首次投资后30天内，均可翻牌2张，并获得2张抵价券；<br/> 2. 已获得的抵价券，可至“我的-优惠券”查收；</br>
        3. 翻牌福利过期无效，请及时翻牌；<br/> 4. 如需协助，请联系暖心客服：400-156-7657<br/></div>
      <div class="small">
        *优选理财拥有法律允许范围内的活动解释权 活动仅成年人可参与，相关理财产品不保证本金和收益，投资有风险，理财需谨慎
      </div>
    </div>
    <mt-popup v-model="popupVisible" popup-transition="popup-slide">
    </mt-popup>
    <div class="pouple animated" :class="{'zoomIn':popupVisible}" v-show="popupVisible">
      <div class="title">
        恭喜您获得首投抵价券
      </div>
       <div class="s_des">以上抵价券15天内有效，请及时使用</div>
      <div class="content">
        <div class="item_sss" v-for="item in selsetcrad">
          <div class="s_1">
            <span>￥</span>{{parseInt(item.money)}}</div>
          <div class="s_2">满{{parseInt(item.quota)}}元<br/> 可用</div>
          <div class="s_3">抵价券</div>
        </div>
      </div>
      <div class="btn" @click="jumpCom()">
        立即查收
      </div>
      <div class="close" @click="popupVisible=false">
        <img src="../../public/imgs/icon-close.png" alt="">
      </div>
    </div>
  </div>
</template>

<script>
import { Popup } from "mint-ui";
export default {
  props: [],
  data() {
    return {
      sessionid: "",
      cardlist: [
        { money: "0", select: false },
        { money: "0", select: false },
        { money: "0", select: false },
        { money: "0", select: false },
        { money: "0", select: false },
        { money: "0", select: false }
      ],
      cont: 0,
      lock: true,
      popupVisible: false,
      selsetcrad: [ ]
    };
  },
  methods: {
    jumpCom() {
      this.Uitis.JumpNavite("jumpToCoupon", "1");
    },
    init() {
      this.$http
        .get(this.Interface.getTopicPaySuccessFlopWeb, {
          params: { sessionid: this.sessionid }
        })
        .then(res => {
          if (res.data.success && res.data.data.list !== null) {
            for (var i = 0; i < res.data.data.list.length; i++) {
              res.data.data.list[i].select = false;
            }
            this.cardlist = res.data.data.list;
            this.cont = res.data.data.rewardSize;
          }
        });
    },
    selset(index) {
      if (this.cont > 0) {
        if (this.cardlist[index].select == true) {
          return false;
        }
        if (this.lock) {
          this.lock = false;
          this.$http
            .get(this.Interface.gettopic_pay_Success_flop_receive, {
              params: { sessionid: this.sessionid }
            })
            .then(res => {
              if (res.data.success) {
                if (res.data.data.money == this.cardlist[index].money) {
                  this.cardlist[index].money = res.data.data.money;
                  this.cardlist[index].quota = res.data.data.quota;
                  this.cardlist[index].select = true;
                  var oc = {};
                  oc.money = res.data.data.money;
                  oc.quota = res.data.data.quota;
                  this.selsetcrad.push(oc);
                } else {
                  for (let i = 0; i < this.cardlist.length; i++) {
                    if (this.cardlist[i].money == res.data.data.money) {
                      var arr = this.cardlist[index];
                      this.cardlist[index] = this.cardlist[i];
                      this.cardlist[i] = arr;
                    }
                  }
                  this.cardlist[index].money = res.data.data.money;
                  this.cardlist[index].quota = res.data.data.quota;
                  this.cardlist[index].select = true;
                  var oc = {};
                  oc.money = res.data.data.money;
                  oc.quota = res.data.data.quota;
                  this.selsetcrad.push(oc);
                }
                this.cont--;
                this.lock = true;
                if (this.cont <= 0) {
                  this.lock = false;
                  setTimeout(() => {
                    for (var i = 0; i < this.cardlist.length; i++) {
                      this.cardlist[i].select = true;
                    }
                  }, 1000);
                  setTimeout(() => {
                    this.popupVisible = true;
                  }, 2000);
                }
              }
            });
        }
      }
    }
  },

  created() {
    this.Uitis.getInfo().then(res => {
      if (res.uId == "") {
        this.isLogin = false;
      } else {
        this.sessionid = res.sessionid;
        this.init();
      }
    });
  }
};
</script>


<style lang="less">
.content {
  height: 100%;
  background: #fff;
}
.s_des{
  font-size: 26px;
  text-align: center;
 color: #666;
 padding: 30px 0px 0px 0px;; 
}
.close{
  position: absolute;
  left: 50%;
  margin-left: -34px;
  bottom: -150px;
  img{width: 68px;}
}
.pouple {
  width: 600px;
  left: 75px;
  position: fixed;
  top: 50%;
  margin-top: -450px !important;
  z-index: 20001;
  background: #fff;
  border-radius: 10px;
  box-sizing: border-box;
  padding: 60px 70px;
  text-align: center;
  .title {
    font-size: 40px;
    color: #333;
    font-weight: bold;
  }
  .btn {
    width: 440px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ff405e;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    border-radius: 10px;
    line-height: inherit;
    height: 80px;
  }
  .content {
    padding: 45px 0px 65px 0px;
    display: flex;
    justify-content: center;
    align-items: center;
    .item_sss {
      background: url(../../public/imgs/buysuccess/card_alert.png) no-repeat;
      background-size: contain;
      height: 300px;
      width: 200px;
      text-align: center;
      box-shadow: 8.192px 5.736px 20px 0px rgba(0, 0, 0, 0.2);
      border-radius: 10px;
      .s_1 {
        color: #ff6b5c;
        font-size: 48px;
        margin-top: 50px;
        font-family: "DinPro";
        span {
          font-size: 34px;
        }
      }
      .s_2 {
        font-size: 28px;
        color: #ff6b5c;
        margin-top: 30px;
          font-family: "DinPro"
      }
      .s_3 {
        font-size: 18px;
        color: #ff6b5c;
        margin-top: 30px;
      }
    }
    .item_sss:first-child {
      margin-right: 30px;
    }
  }
}

.item_sss {
  background: url(../../public/imgs/buysuccess/card_alert.png) no-repeat;
  background-size: contain;
  height: 300px;
  width: 200px;
  text-align: center;
  box-shadow: 8.192px 5.736px 20px 0px rgba(0, 0, 0, 0.2);
  border-radius: 10px;
 .s_1 {
        color: #ff6b5c;
        font-size: 48px;
        margin-top: 50px;
          font-family: "DinPro";
        span {
          font-size: 34px;
        }
      }
      .s_2 {
        font-size: 28px;
        color: #ff6b5c;
        margin-top: 30px;
          font-family: "DinPro"
      }
  .s_3 {
    font-size: 18px;
    color: #ff6b5c;
    margin-top: 30px;
  }
}
.nav {
  margin: 0 auto;
  width: 671px;
  height: 80px;
  background: url(../../public/imgs/buysuccess/choujiang_nav.png) no-repeat;
  background-size: contain;
  margin-top: 40px;
  font-size: 34px;
  color: #fff;
  font-weight: bold;
  display: flex;
  align-items: center;
  padding-left: 50px;
  box-sizing: border-box;
  margin-bottom: 30px;
}
.card_content {
  display: flex;
  width: 670px;
  box-sizing: border-box;
  margin: 0 auto;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  .item {
    width: 200px;
    height: 300px;
    background-size: contain;
    border-radius: 10px;
    position: relative;
    margin-bottom: 25px;
    position: relative;
    transition: 1s;
    transform-style: preserve-3d;
    img {
      border-radius: 10px;
      position: absolute;
      top: 0px;
      left: 0px;
      width: 200px;
      height: 300px;
      box-shadow: 8.192px 5.736px 20px 0px rgba(0, 0, 0, 0.2);
      backface-visibility: hidden;
    }
    .item_sss {
      background: url(../../public/imgs/buysuccess/card_alert.png) no-repeat;
      background-size: contain;
      border-radius: 10px;
      top: 0px;
      left: 0px;
      width: 200px;
      height: 300px;
      box-shadow: 8.192px 5.736px 20px 0px rgba(0, 0, 0, 0.2);
      transform: rotateY(180deg);
      backface-visibility: hidden;
      position: absolute;
      -webkit-backface-visibility: hidden;
    }
  }
}
.active {
  transform: rotateY(180deg);
}
.rules {
  width: 670px;
  margin: 0 auto;
  margin-top: 36px;
  padding-bottom: 30px;
  .title {
    font-size: 30px;
    font-weight: bold;
    font-family: "苹方";
    color: #333;
    margin-bottom: 25px;
  }
  .des_a {
    font-size: 26px;
    color: #666;
    line-height: 40px;
  }
  .small {
    font-size: 22px;
    color: #666;
    line-height: 40px;
    margin-top: 20px;
  }
}
</style>
